home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPCheckBox.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.0 KB  |  77 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/23/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPCheckBox
  6.     
  7.     SUPERCLASS: CPPControl
  8.     
  9.         This C++ class manages a checkbox control
  10.     
  11. ********************************************************************/
  12.  
  13. #include <CPPCheckBox.h>
  14.  
  15. extern    Rect    kDefaultRect;
  16. extern    Rect    kEmptyRect;
  17.  
  18. /*-----------------------------------------------------------------*/
  19. /*------------------------ PUBLIC METHODS -------------------------*/
  20. /*-----------------------------------------------------------------*/
  21.  
  22.     CPPCheckBox::CPPCheckBox (CPPWindow *itsWindow, short ResID,
  23.                              Boolean initiallyOn,
  24.                              Boolean canBeTarget,
  25.                              Boolean active, Boolean visible) :
  26.                 CPPControl (itsWindow, ResID, FALSE, canBeTarget, 
  27.                                  active, visible)
  28.     /* load a control resource and initialize with the given data */
  29.     {
  30.         
  31.         if (this->theControl)
  32.           SetValue (initiallyOn);
  33.     }
  34.  
  35. /*-----------------------------------------------------------------*/
  36.  
  37.     CPPCheckBox::CPPCheckBox (CPPWindow *itsWindow, Rect *itsBounds,
  38.                              StringPtr itsText, Boolean initiallyOn,
  39.                               Boolean useWindowFont,
  40.                              Boolean canBeTarget,
  41.                              Boolean active, Boolean visible) :
  42.                 CPPControl (itsWindow, itsBounds, checkBoxProc,
  43.                             itsText, FALSE, useWindowFont,
  44.                             canBeTarget, active, visible)
  45.     {
  46.         if (this->theControl)
  47.           SetValue (initiallyOn);
  48.     }
  49.  
  50. /*-----------------------------------------------------------------*/
  51.  
  52.     CPPCheckBox::~CPPCheckBox (void)
  53.     {
  54.  
  55.     }
  56.  
  57. /*-----------------------------------------------------------------*/
  58.  
  59.     char    *CPPCheckBox::ClassName (void)
  60.     {
  61.         return "CPPCheckBox";
  62.     }
  63.  
  64. /*-----------------------------------------------------------------*/
  65.  
  66.     void    CPPCheckBox::DoOnClick (void)
  67.     /* toggle the value of the checkbox when it is clicked on */
  68.     /* SUBCLASS MAY OVERRIDE */
  69.     {
  70.         if (this->theControl)
  71.           SetValue ((GetValue() + 1) % 2);
  72.           
  73.         // let the superclass run the callback proc
  74.         CPPControl::DoOnClick();
  75.     }
  76.  
  77.